package main

import (
	"fmt"
	"gopkg.in/yaml.v2"
	"io/ioutil"
)

func main() {
	config := &ServerConfig{8080, "kpsaas"}
	bytes, err := yaml.Marshal(config)
	if err != nil {
		fmt.Printf("marshal to yaml error.%v", err)
		return
	}
	fmt.Println("content is ", string(bytes))

	file, err := ioutil.ReadFile("yaml/config.yaml")
	if err != nil {
		fmt.Printf("read file error", err)
		return
	}
	yaml.Unmarshal(file, config)
	fmt.Println(config)

}

type ServerConfig struct {
	Port int32
	Name string
}